package jp.ne.hatena.d.digitalsoul.warikan.contexts

import jp.ne.hatena.d.digitalsoul.warikan.contexts.rootpopulaters._
import jp.ne.hatena.d.digitalsoul.warikan.models._
import jp.ne.hatena.d.digitalsoul.warikan.repositories._
import jp.ne.hatena.d.digitalsoul.warikan.roles._

class Preparation extends SlopePopulater {
	
	var administrator:Administrator = null
	
	var slope:Slope = null
	
	def setup(name:String) = {
		
		val id = SlopeRepository.nextId
		
	    this.administrator = new Slope(id, name) with Administrator
	    this.slope = populateSlope(administrator)
		
	}
	
	def slopeId:String = slope.id
	
	def slopeName = slope.name 
	
	def populate(id:String) = {
		this.administrator = new Slope(id) with Administrator
	    this.slope = populateSlope(administrator)
	}
	
	def addMapping(role:String, weight:Int) = 
		administrator.addMapping(role, weight)
		
	def commit = SlopeRepository.add(slope)

}